#code for the optimizer
Explore tagged Tumblr posts
mentalisttraceur-software · 2 years ago
Text
When I was younger and still stuck thinking in terms of concrete current implementations more than abstract semantics and their best possible implementations, I kept wanting to bypass the standard library, especially in low-level languages like C, because the standard library had code paths I didn't need.
If I knew I didn't need my newly allocated memory to start zeroed out, I disliked calling calloc, because a naive implementation of calloc implies extra work, and most implementations would imply extra work at least some of the time. Because I failed to conceive of the OS and hardware having extremely efficient code and circuitry for giving us zeroed out memory pages, and I failed to conceive of optimizing compilers generating code which doesn't bother zeroing out that memory if you truly never read those bytes before writing them.
If I just wanted one memory allocation for the lifetime of the program, I disliked calling malloc at all, because most malloc implementations have a complex memory allocator which is only more optimal for larger and churnier memory usage. I wanted to call the rawest, most direct memory allocation operation - for example, on modern Linux that's an mmap system call asking for an anonymous page (or for a mapping of /dev/zero, although I later learned of sloppy/overbroad SELinux policies in production, f.e. on some Android devices, which reject opening or mapping /dev/zero). Or I wanted to just manually try to grow the stack (and have raw feedback from the kernel if I didn't have enough). Because I was stuck thinking about what the concrete implementations I had on hand would do. Instead, I should've been imagining the optimizing compiler which can look at a simple "malloc", and at everything else in the code, and at any optimization preferences and other information passed in when invoking the compiler, and just compile that malloc as a raw memory system call, or as a stack allocation, if that's actually the best thing to do in that situation.
Painstakingly chipping away at this has been one of the most liberating and healing things for me as a software developer. This is why I eventually realized that we should "code for the optimizer" rather than optimizing by hand in almost every situation. But it took the overwhelming accumulation of examples of actual real-world situations where automatic optimizations beat manual fiddling, or did just as well, and where the manual fiddling was actively counter-productive.
I wish they taught this in schools or something. Just one class, one semester, which is mostly just a showcase of "here's some code. here's how it could be inefficient. how might we optimize this? yeah, yeah, cool, cool... good ideas class. Now here's what a modern compiler can do if you just give it the simple code that doesn't try to optimize. Notice how it did everything you thought of, plus things you didn't. And oh look, if we change the optimization tuning from execution speed to memory usage for example, the compiler can optimize the simple code totally differently, but our hand-optimized code is stuck using more memory, because the compiler can no longer discern the relevant intent and invariants in this code - and neither could a human, without extensive comments and context".
I know lots of developers just don't care, but it would go a long way towards either unblocking or constructively directing the type of developer who can be very productive but would otherwise spend too much time prematurely or needlessly optimizing in the wrong places.
17 notes · View notes
soupysuki · 6 months ago
Text
Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media
the universe question
228 notes · View notes
ryonello · 10 months ago
Text
Tumblr media
i have ........... a new meowmeow fixation .........
369 notes · View notes
tragedytells-tales · 6 days ago
Text
Tumblr media
Today's warm up doodle, when the journey to the west has a monkie kid and it's epic
Open Arms is what would've happened had Wukong found out about Macaque training MK sooner and MK made it his mission to make them get along
48 notes · View notes
agerasiaa · 2 months ago
Text
legacy? no babe, that’s just the trauma pipeline with extra steps. and lifelong performance review I never asked for
44 notes · View notes
taldigi · 19 days ago
Text
Tumblr media
but look at thebullshit i had to pull just to get the textboxes to tilt
and you know what they wouldn't let me put an img between box-shadow and the box so
@kumakechi thank you for your prayers
8 notes · View notes
dekusleftsock · 11 months ago
Text
Tumblr media Tumblr media
Leaks aren’t until tomorrow we can prepare🙏🙏🙏
And sorry to be that person but unless you can say you will not freak out in any way at the end of the manga tomorrow, I sincerely advise that you take a break. It is, of course, a superhero comic, and while I can say that it genuinely changed my own ideals about morality..or life in general—it’s still just a story, at the end of the day. It is fictional. Turn off tumblr and Twitter and tiktok, or better yet, delete them. For the day. Just chill. Have fun.
Actually, delete them today! Delete delete delete. Take care of yourself. Don’t torture yourself by going through all the anxieties and what ifs and doom scrolling.
The manga is supposed to be something fun to look forward to, it shouldn’t dictate your life if you can help it.
So good luck, have a glass of water, touch some grass, go see your mother, and I wish you all fulfillment and happiness regarding the ending.
Thank you so much mha for all the memories—so until tomorrow, goodnight!
32 notes · View notes
stormyrainyday · 5 months ago
Text
beyblade (metal fight) and genshin fans please lend me your strength in designing a special move for Bennett and freminet I've made Bennett a balance type bey (blitz tempo) and freminet an attack type (spiral byxis) they're both on my blog I'll link it in the morning if I remember but I have an idea cooking for them but I need to assign them special moves before it can happen
10 notes · View notes
mentalisttraceur-software · 2 years ago
Text
A little example of clear abstract code "aging efficient":
if you use Arm's solution in pure software to implement pow(x,y) on an x86 machine, then it'll go 5x faster than Intel's native x87 instructions for doing the same thing. [alleged here]
If true, and I suspect it is (I would just want to verify how/why, and if any edge cases were left on the cutting room floor, just in case) then code which went out of its way to use inline assembly instead of the "pow" C function is now slower - assuming your C library or compiler takes advantage of these techniques (notably, even if there are edge cases where it behaves differently than the instruction, if the C compiler can prove that you will never hit them, or if it would be undefined behavior per the C standard to hit them, your code could benefit from this at any time).
Code for the optimizer.
11 notes · View notes
tosahobi-if · 1 year ago
Note
do you have any art of ??? i feel like everyone but ???mancers are getting fed 😔
Tumblr media
HAHAHA of course! here's a sketch i've been working on of ??? recently. i'm going to attempt to paint it so wish me luck (´ཀ` )
40 notes · View notes
ahalliance · 7 months ago
Text
beginning the qetoiles narrative playlist with undertale’s “hopes and dreams”, a very powerful and uplifting music, and later down the line having a melancholic song with the lyrics “all of your dreams / swallowed in the heat of the sun” is perhaps me cooking tbh….
12 notes · View notes
slime-crafters · 5 months ago
Text
Go by the most amount of copies you own - I own three copies of stardew valley across different platforms, for instance, so I'd pick the option for three. Include digital and physical media across any platform (mobile or obsolete consoles included). As long as you own it in some way, include it
7 notes · View notes
pokemondetector · 5 months ago
Note
How does your thing work??? I thought at first you were reading the post in as a string and doing like a key-dictionary thing to match a pattern with a Pokémon name but it didn’t do it with the Ask containing the pokérap. I am v curious and would love to hear about it if you have time
Pokemon detected :
How does your thing work??? I thought at first you were reading the post in as a string and doing like a key-dictionary thing to match a pattern with a Pokémon name but it didn’t do it with the Ask containing the pokérap. I am v curious and would love to hear about it if you have time
Tumblr media
Ralts !
13 notes · View notes
hua-fei-hua · 3 months ago
Text
y'know, i really do appreciate the ability to overload/overwrite operators in c++. absolute 10/10 ability for a coding language to have.
3 notes · View notes
starburstgalexies · 7 months ago
Text
I found out one of my rejections is because, the program I wrote alone over 3 days, was not efficient enough.
Brother if you want anything better
give me more time
pay me
5 notes · View notes
welcomeinitiate · 7 months ago
Note
soccer chef is sooo fun! I need a full version of it ASAP
question though, I made bicycle kick although that's not in the recipe book?
Thanks!!! It was incredibly fun to make and also a giant mess of spaghetti. The way I made it was a little unhinged in that I used global variables and had the game reset each time you click the pot lid
Tumblr media
There are four dishes that were implemented but not listed in the recipe section as they weren't helpful to the puzzle solve: Hand Ball, Drop Ball, Bicycle Kick, and Kick Off--looks like you figured one of them out!
5 notes · View notes